﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace BanVeXemPhim_Presentation
{
    class LoaiGheDAO : DataProvider
    {
        public LoaiGheDTO[] LayDanhSachLoaiGhe()
        {
            connect();
            string query = "select * from LoaiGhe";
            adapter = new SqlDataAdapter(query, connection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet);
            DataTable dataTable = dataSet.Tables[0];
            int n = dataTable.Rows.Count;
            LoaiGheDTO[] dsLoaiGhe= new LoaiGheDTO[n];
            for (int i = 0; i < n; i++)
            {
                LoaiGheDTO loaigheDto= (LoaiGheDTO)GetDataFromDataRow(dataTable, i);
                dsLoaiGhe[i] = loaigheDto;
            }
            return dsLoaiGhe;
        }

        protected override object GetDataFromDataRow(System.Data.DataTable dt, int i)
        {
            LoaiGheDTO loaigheDto= new LoaiGheDTO();
            loaigheDto.IdLoaiGhe= Convert.ToInt32(dt.Rows[i]["IdLoaiGhe"].ToString());
            loaigheDto.TenLoaiGhe= dt.Rows[i]["TenLoaiGhe"].ToString();
            return loaigheDto;
        }
    }
}
